﻿using Ardalis.Specification;
using Domain.Entities.Modulers;

namespace NM.Module.Manager.API.Specifications;

#nullable disable

public class ModulerAdvancedPaginationSpec : Specification<Moduler>
{
    public ModulerAdvancedPaginationSpec(ModulerAdvancedFilter filter)
    {
        Query
            .Where(x => x.Title.Contains(filter.Keyword) || x.Name.Contains(filter.Keyword), !string.IsNullOrWhiteSpace(filter.Keyword))
            .Where(x => x.Title == filter.Title, !string.IsNullOrWhiteSpace(filter.Title))
            .Where(x => x.Name == filter.Name, !string.IsNullOrWhiteSpace(filter.Name))
            .Where(x => x.Version == filter.Version, !string.IsNullOrWhiteSpace(filter.Version));
    }
}